import { ref, computed } from "vue-demi"
import { useStore } from "@/store"
function useState() {
  const store = useStore()
  const btnLoading = ref<boolean>(false)

  // 判断是否为可编辑文档
  const editable = computed(() => {
    if (store.state.markdown.editable) {
      return true
    } else {
      if (store.state.markdown.user.id === store.state.user.id) {
        return true
      }
      return false
    }
  })

  // 判断文档是否被占用
  const occupied = computed(() => {
    if (store.state.markdown.occupyUser) {
      return true
    }
    return false
  })
  return { btnLoading, editable, occupied }
}
export default useState
